<% layout('/layouts/default.html', {title: '专项工作-事项清单管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('专项工作-事项清单数据导入')}
			</div>

		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${dcSupSpecialWork}" action="${ctx}/specialWork/dcSupSpecialWork/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('日期')}：</label>
				<div class="control-inline">
					<#form:input path="importTime" readonly="true" maxlength="10" class="form-control laydate width-date"
					dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
				</div>
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
				<a href="#" class="btn btn-default" id="btnImport"><i class="glyphicon glyphicon-import"></i> ${text('导入')}</a>
			</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	sortable:false,
	sortableColumn: false,
	frozenCols: true,
	columnModel: [
		{header:'${text("序号")}', name:'taskNum', index:'a.task_num', width:50, align:"left", frozen:true},
		{header:'${text("导入日期")}', name:'importTime', index:'a.import_time', width:120, align:"center", frozen:true},
		{header:'${text("事项类别")}', name:'taskType', index:'a.task_type', width:150, align:"left"},
		{header:'${text("任务描述")}', name:'taskContent', index:'a.task_content', width:150, align:"left"},
		{header:'${text("责任单位编码")}', name:'leaderOrgCode', index:'a.leader_org_code', width:150, align:"left"},
		{header:'${text("责任单位名称")}', name:'leaderOrgName', index:'a.leader_org_name', width:150, align:"left"},
		{header:'${text("调度人")}', name:'dispatcherName', index:'a.dispatcher_name', width:150, align:"left"},
		{header:'${text("目前进展")}', name:'feedbackContent', index:'a.feedback_content', width:150, align:"left"},
		{header:'${text("任务开始时间")}', name:'taskStartTime', index:'a.task_start_time', width:150, align:"center"},
		{header:'${text("任务结束时间")}', name:'taskEndTime', index:'a.task_end_time', width:150, align:"center"},
		{header:'${text("最近一次要求反馈时间点")}', name:'latestRequireTime', index:'a.latest_require_time', width:170, align:"center"},
		{header:'${text("最近一次反馈时间")}', name:'latestFeedbackTime', index:'a.latest_feedback_time', width:150, align:"center"},
		{header:'${text("存在问题")}', name:'feedbackAdvice', index:'a.feedback_advice', width:150, align:"left"},
		{header:'${text("联系人")}', name:'contactName', index:'a.contact_name', width:150, align:"left"},
		{header:'${text("联系人电话")}', name:'contactPhone', index:'a.contact_phone', width:150, align:"left"},
		{header:'${text("完成率(%)")}', name:'completeRate', index:'a.complete_rate', width:150, align:"center"},
		{header:'${text("任务备注")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("推进状态")}', name:'taskProgress', index:'a.task_progress', width:150, align:"left"},


	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
// 导入
$('#btnImport').click(function(){
	let selectDate = $('#importTime').val();
	js.layer.open({
		type: 1,
		area: ['400px'],
		title: '${text("导入数据")}',
		resize: false,
		scrollbar: true,
		shadeClose: false,
		content: js.template('importTpl'),
		success: function(layero, index){
			layero.find('input[type="checkbox"]').iCheck();
			layero.find('#importTime').val(selectDate);
		},
		btn: ['<i class="fa fa-check"></i> ${text("导入")}',
			'<i class="fa fa-remove"></i> ${text("关闭")}'],
		btn1: function(index, layero){
			var form = {
				inputForm: layero.find('#inputForm'),
				file: layero.find('#file').val()
			};
			if(!selectDate){
				js.showMessage("${text('请选择日期')}", null, 'warning');
				return false;
			}
			if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
				js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
				return false;
			}
			js.ajaxSubmitForm(form.inputForm, function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.layer.closeAll();
				}
				page();
			}, "json");
			return true;
		}
	});
});
</script>

<script id="importTpl" type="text/template">//<!--

<form id="inputForm" action="${ctx}/specialWork/dcSupSpecialWork/importData" method="post" enctype="multipart/form-data"
	class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
	<div class="row">
		<div class="col-xs-12 col-xs-offset-1">
			<input type="file" id="file" name="file" class="form-file"/>
			<font color="red" class="pull-left mt10">
			${text('提示：选择日期后导入会覆盖之前相对应日期的数据')}
			</font>
			<input type="date" id="importTime" name="importTime" style="display:none;">
			<div class="mt10 pt5">
				<a href="${ctxStatic}/专项工作导入模板.xlsx" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
			</div>
			<font color="red" class="pull-left mt10">
				${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
			</font>
		</div>
	</div>
</form>
//--></script>